export default {
  typeof (o) {
    return Object.prototype.toString.call(o).match(/ ([^\]]*)/)[1].toLocaleLowerCase()
  },
  hasRepeat (list1, list2) {
    let hasRepeat = false
    for (let i = 0; i < list1.length; i++) {
      for (let j = 0; j < list2.length; j++) {
        if (list1[i] === list2[j]) {
          hasRepeat = true
          break
        }
      }
    }
    return hasRepeat
  },
  clone (o) {
    let clone = (o) => {
      let type = this.typeof(o)
      if (['number', 'string', 'boolean', 'null', 'undefined', 'regexp'].indexOf(type) > -1) {
        return o
      } else if (type === 'array') {
        let t = []
        for (let i = 0, l = o.length; i < l; i++) {
          t.push(clone(o[i]))
        }
        return t
      } else {
        let t = {}
        for (let k in o) {
          t[k] = clone(o[k])
        }
        return t
      }
    }
    return clone(o)
  }
}
